# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 13:35:20 2013

@author: Maxim
"""

import numpy as np
import aircraft
import aerodynamics
import matplotlib.pyplot as plt
import matplotlib
import FlightConditions as FC
import mass
from warnings import warn
import report_tools as rt

def get_mass_data():
    names = ['Case 1','Case 2','Case 3', 'Case 4']
    mass = np.array([420.0,620,490,580])
    CG = list()
    CG.append(np.array([1757.0,-34,-125]))
    CG.append(np.array([1784.0,-1,-96]))
    CG.append(np.array([1914.0,-29,-125]))
    CG.append(np.array([1897.0,-24,-158]))
    CG = [cg/1000.0 for cg in CG]
    return names, mass, CG

def generate_stability_report():
    ac = aircraft.load('V0510')
    names,massList,cgList = get_mass_data()
    velocity = 60.0
    density = 1.0581
    loadFactor = 1.0
    aero = aerodynamics.aerodynamics(ac)
    out = ''
    show = [True,False,False,False]
    for name,m,cg,s in zip(names,massList,cgList,show):
        aero.update(velocity,density,loadFactor,name=name,mass=m,CG=cg)
        sr = rt.StabilityTextReport(aero.results,velocity,m,cg)
        out += sr._report(s,dynamic=True) + '\n'
    print out


if __name__=="__main__":
    generate_stability_report()